function zjsj_onclick() {
    $("#wrapper").html("<form class=\"sendForm\">\n" +
        "                <div class=\"form-group\">\n" +
        "                    <label for=\"exampleInputName2\">平台</label>\n" +
        "                    <select class=\"form-control\" name=\"platform\">\n" +
        "                        <option value=\"\">请选择</option>\n" +
        "                        <option value=\"支付宝小程序\">支付宝小程序</option>\n" +
        "                        <option value=\"钉钉小程序\">钉钉小程序</option>\n" +
        "                    </select>\n" +
        "                </div>\n" +
        "                <div class=\"form-group\">\n" +
        "                    <label for=\"exampleInputEmail2\">数据维度</label>\n" +
        "                    <select class=\"form-control\" name=\"data_dimension\">\n" +
        "                        <option value=\"\">请选择</option>\n" +
        "                        <option value=\"直播数据\">直播数据</option>\n" +
        "                        <option value=\"消息分析\">消息分析</option>\n" +
        "                        <option value=\"内容分析\">内容分析</option>\n" +
        "                    </select>\n" +
        "                </div>\n" +
        "                <div class=\"form-group\">\n" +
        "                    <label for=\"exampleInputEmail2\">公众号平台</label>\n" +
        "                    <select id=\"select1\" onchange='select_change()' class=\"form-control\" name=\"official_accounts\">\n" +
        "                        <option value=\"\">请选择</option>\n" +
        "                        <option id=\"item1\" value=\"生活号\">生活号</option>\n" +
        "                        <option id=\"item2\" value=\"看看号\">看看号</option>\n" +
        "                    </select>\n" +
        "                </div>\n" +
        "                <div class=\"form-group\">\n" +
        "                    <label for=\"exampleInputEmail2\">公众号名称</label>\n" +
        "                    <select id=\"select2\" class=\"form-control\" name=\"official_accounts_name\">\n" +
        "                            <option  value=\"\">请选择<option>\n" +
        "                    </select>\n" +
        "                </div>\n" +
        "                <div class=\"form-group\">\n" +
        "                    <input name=\"Files\" type=\"file\" id=\"exampleInputFile1\">\n" +
        "                </div>\n" +
        // 添加了id属性
        "                <button type=\"button\" onclick='upload_file()' class=\"btn btn-default\">提交</button>\n" +
        "            </form>")
    // document.reload()
    // console.log("x")
}


function select_change() {
    // console.log($("#select1").val())
    var val = $("select[name='official_accounts']").val();
    // console.log(val)
    if (val == "生活号") {
        $("#select2").html(
            "                        <option value=\"直播数据\">直播数据</option>\n" +
            "                        <option value=\"消息分析\">消息分析</option>\n" )
    } else if (val == "看看号") {
        $("#select2").html(
            "                        <option value=\"直播数据\">直播数据</option>\n" +
            "                        <option value=\"消息分析\">消息分析</option>\n" )
    }
}

function zbgs_onclick() {
    $("#wrapper").html(" <form class=\"sendForm\">\n" +
        "\n" +
        "        <div class=\"form-group\">\n" +
        "          <input name=\"Files\" type=\"file\" id=\"exampleInputFile2\">\n" +
        "        </div>\n" +
        "        <button type=\"button\" onclick='zbgs()'  class=\"btn btn-default\">提交</button>\n" +
        "      </form>")
}

function upload_file() {
    var formData = new FormData();
    var platform = $("select[name='platform']").val()
    var data_dimension = $("select[name='data_dimension']").val()
    var official_accounts = $("select[name='official_accounts']").val()
    var official_accounts_name = $("select[name='official_accounts_name']").val();

    formData.append("platform", platform);
    formData.append("data_dimension", data_dimension);
    formData.append("official_accounts", official_accounts);
    formData.append("official_accounts_name", official_accounts_name);
    formData.append("Files", $("#exampleInputFile1")[0].files[0]);
    $.ajax({
        url: '/data_import/upload',
        type: 'POST',
        data: formData,
        dataType: "json",
        processData: false,
        contentType: false,
        success: function (data) {
            if (data.code == 200) {
                alert("上传成功")
            } else {
                alert(data.message)
            }
        },
    })
    return false;
};

//直播公司
function zbgs() {
    var formData = new FormData();
    formData.append("Files", $("#exampleInputFile2")[0].files[0]);
    $.ajax({
        url: '/data_import/upload_livestream_company',
        type: 'POST',
        data: formData,
        dataType: "json",
        processData: false,
        contentType: false,
        success: function (data) {
            if (data.code == 200) {
                alert("上传成功")
            } else {
                alert(data.message)
            }
        },

    })
    return false;
};